
<!DOCTYPE html>
<html class="no-js">
<head lang="en">

    <#include "../head_import.html" />

</head>
<body>
<#include "../include/top_nav.html">
    <div class="am-cf admin-main">

        <!-- sidebar start -->
        <#include "../template/left.html">
            <!-- sidebar end -->
            <!-- content start-->
            <div class="admin-content">
                <div class="am-cf am-padding">
                    <div class="am-fl am-cf"><@s.m "global.position"/>: <@s.m "template.function"/> - <@s.m "global.edit"/></div>
                </div>
                <div class="am-g">
                    <div class="am-u-sm-12 am-u-sm-centered">
                        <form class="ropt">
                            <input type="button" value="<@s.m "global.backToList"/>" onclick="history.back();"/>
                        </form>
                        <div class="clear"></div>
                    </div>
                </div>
                <div class="am-g">
                    <div class="am-u-sm-12 am-u-sm-centered">
                        <@p.form id="baseForm" action="o_update.do" labelWidth="12" onsubmit="ajaxSubmit();return false;">
                        <@p.text label="template.name" id="filename" name="filename" value=template.filename size="30" readonly="readonly"/>
                        <@p.textarea label="template.content" id="source" name="source" value=template.source wrap="off" style="width:99%" rows="20" cols="70" maxlength="131072" help="template.content.help" helpPosition="1" onkeydown="if((event.keyCode==115||event.keyCode==83)&&event.ctrlKey){ajaxSubmit();return false;}"/>
                        <@p.td>
                        <@p.hidden id="name" name="name" value=template.name/>
                        <@p.hidden id="root" name="root" value=root/>
                        <@p.submit code="global.submit"/> &nbsp; <@p.reset code="global.reset"/>
                    </@p.td>
                </@p.form>
            </div>
    </div>



    </div>

    </div>
</body>
</html>



<script type="text/javascript">
    function ajaxSubmit() {
        $.post('o_update.do', {
            "root" : $("#root").val(),
            "name" : $("#name").val(),
            'source' : $('#source').val()
        }, function(data) {
            if (data) {
                alert("<@s.m 'global.success.save'/>");
            } else {
                alert("<@s.m 'global.failed.save'/>");
            }
        }, 'json');
    }
</script>